package com.tea.funct.service.impl;

import com.tea.common.utils.DateUtils;
import com.tea.funct.domain.TeaPriceDetails;
import com.tea.funct.mapper.TeaPriceDetailsMapper;
import com.tea.funct.service.ITeaPriceDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 价格明细Service业务层处理
 *
 * @author Sophia
 * @date 2024-05-25
 */
@Service
public class TeaPriceDetailsServiceImpl implements ITeaPriceDetailsService {
    @Autowired
    private TeaPriceDetailsMapper teaPriceDetailsMapper;

    /**
     * 查询价格明细
     *
     * @param id 价格明细主键
     * @return 价格明细
     */
    @Override
    public TeaPriceDetails selectTeaPriceDetailsById(Long id) {
        return teaPriceDetailsMapper.selectTeaPriceDetailsById(id);
    }

    /**
     * 查询价格明细列表
     *
     * @param teaPriceDetails 价格明细
     * @return 价格明细
     */
    @Override
    public List<TeaPriceDetails> selectTeaPriceDetailsList(TeaPriceDetails teaPriceDetails) {
        return teaPriceDetailsMapper.selectTeaPriceDetailsList(teaPriceDetails);
    }

    /**
     * 新增价格明细
     *
     * @param teaPriceDetails 价格明细
     * @return 结果
     */
    @Override
    public int insertTeaPriceDetails(TeaPriceDetails teaPriceDetails) {
        if (teaPriceDetails.getCreateTime() == null) {
            teaPriceDetails.setCreateTime(DateUtils.getNowDate());
        }
        return teaPriceDetailsMapper.insertTeaPriceDetails(teaPriceDetails);
    }

    /**
     * 修改价格明细
     *
     * @param teaPriceDetails 价格明细
     * @return 结果
     */
    @Override
    public int updateTeaPriceDetails(TeaPriceDetails teaPriceDetails) {
        teaPriceDetails.setUpdateTime(DateUtils.getNowDate());
        return teaPriceDetailsMapper.updateTeaPriceDetails(teaPriceDetails);
    }

    /**
     * 批量删除价格明细
     *
     * @param ids 需要删除的价格明细主键
     * @return 结果
     */
    @Override
    public int deleteTeaPriceDetailsByIds(Long[] ids) {
        return teaPriceDetailsMapper.deleteTeaPriceDetailsByIds(ids);
    }

    /**
     * 删除价格明细信息
     *
     * @param id 价格明细主键
     * @return 结果
     */
    @Override
    public int deleteTeaPriceDetailsById(Long id) {
        return teaPriceDetailsMapper.deleteTeaPriceDetailsById(id);
    }

    @Override
    public void insertTeaPriceDetailsAll(List<TeaPriceDetails> dList) {
        teaPriceDetailsMapper.insertTeaPriceDetailsAll(dList);
    }

    @Override
    public TeaPriceDetails selectTeaPriceDetailsByProductId(Long productId) {
        return teaPriceDetailsMapper.selectTeaPriceDetailsByProductId(productId);
    }

    @Override
    public List<TeaPriceDetails> selectTeaPriceDetailListByProductId(Long productId) {
        return teaPriceDetailsMapper.selectTeaPriceDetailListByProductId(productId);
    }

    @Override
    public List<TeaPriceDetails> selectTeaPriceDetailsListByProductIdAndDay(Long productId, Long day) {
        return teaPriceDetailsMapper.selectTeaPriceDetailsListByProductIdAndDay(productId, day);
    }

    @Override
    public Integer syncInsertTeaPriceDetailsData(List<Long> productIds) {
        return teaPriceDetailsMapper.syncInsertTeaPriceDetailsData(productIds);
    }

    @Override
    public List<Long> selectHasInPriceDetailsListByProductIdsAndTime(List<Long> productIds) {
        return teaPriceDetailsMapper.selectHasInPriceDetailsListByProductIdsAndTime(productIds);
    }

    @Override
    public Integer insertOrUpdateDetails(List<TeaPriceDetails> list) {
        return teaPriceDetailsMapper.insertOrUpdateDetails(list);
    }
}
